package de.wittekind.bundesjugendspiele.server.interfaces;

import java.util.ArrayList;
import java.util.List;

public enum Discipline {

	WURF80, WURF200, STOSS3000, STOSS4000, STOSS5000, STOSS6250, WEITSPRUNG, HOCHSPRUNG, SPRINT50, SPRINT75, SPRINT100, SCHLEUDERBALL, AUSDAUER800, AUSDAUER1000, AUSDAUER2000, AUSDAUER3000,
	// Gruppen
	WURF(WURF80, WURF200),

	STOSS(STOSS3000, STOSS4000, STOSS5000, STOSS6250),

	SPRUNG(WEITSPRUNG, HOCHSPRUNG),

	SPRINT(SPRINT50, SPRINT75, SPRINT100),

	AUSDAUER(AUSDAUER800, AUSDAUER1000, AUSDAUER2000, AUSDAUER3000);

	private Discipline[] group;
	private static Discipline[] groups;

	private Discipline(Discipline... args) {
		group = args;
	}

	private Discipline() {
		group = new Discipline[] { this };
	}

	public Discipline[] getDisciplines() {
		return group;

	}

	public boolean isGroup() {
		if (group.length == 1)
			return false;
		return true;
	}

	public boolean hasDiscipline(Discipline discipline) {
		for (Discipline searchDiscipline : group) {
			if (searchDiscipline.equals(discipline))
				return true;
		}
		return false;
	}

	public static Discipline[] getGroups() {
		if (groups == null) {
			List<Discipline> list = new ArrayList<Discipline>();

			for (Discipline d : Discipline.values()) {
				if (d.isGroup())
					list.add(d);
			}
			groups = list.toArray(new Discipline[] {});
		}
		return groups;
	}

	public String shortString() {
		switch (this) {
		case AUSDAUER1000:
			return "1000m";
		case AUSDAUER2000:
			return "2000m";
		case AUSDAUER3000:
			return "3000m";
		case AUSDAUER800:
			return "800m";
		case HOCHSPRUNG:
			return "hoch";
		case SPRINT100:
			return "100m";
		case SPRINT50:
			return "50m";
		case SPRINT75:
			return "75m";
		case STOSS3000:
			return "3kg";
		case STOSS4000:
			return "4kg";
		case STOSS5000:
			return "5kg";
		case STOSS6250:
			return "6,25kg";
		case WEITSPRUNG:
			return "weit";
		case WURF200:
			return "200g";
		case WURF80:
			return "80g";
		default:
			return toString();
		}
	}
}
